package blackitheima1.ClassDemo;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

//类加载器常用方法
public class MyClass {
    public static void main(String[] args) throws IOException {
        //获取系统类加载器
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        //获取平台类加载器
        ClassLoader classLoader1 = systemClassLoader.getParent();
        //获取内置加载器
        ClassLoader classLoader2 = classLoader1.getParent();

        //通过系统类加载器调用方法,获取src类下的文件
        InputStream resourceAsStream = systemClassLoader.getResourceAsStream("prop.properties");

        //创建properties(类似Map集合)对象
        Properties prop=new Properties();
        //读入字节流
        prop.load(resourceAsStream);
        //提取键值
        String classname = prop.getProperty("Classname");
        System.out.println(classname);

    }
}
